<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" type="text/css" href="{{CDN}}/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="{{CDN}}/easyui/themes/icon.css">
		<script type="text/javascript" src="{{CDN}}/easyui/jquery.min.js"></script>
		<script type="text/javascript" src="{{CDN}}/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="{{CDN}}/easyui/locale/easyui-lang-zh_CN.js"></script>
        <script>
            var selectRow = null;//全局变量，当前选中的行
            $(function(){
                /*左侧表格初始化*/
                $("#grid").datagrid({
                    singleSelect:true,
                    fit:true,
                    fitColumns:true,
                    collapsible:true, 
                    striped:true,
                    rownumbers:true, 
                    columns:[[    
                        {field:'CK',checkbox:true},  
                        {field:'cert_dict_id',title:'主键',width:20,align:'center'}, 
                        {field:'qualifi_type',title:'qualifi_type',width:70,align:'right'},
                        {field:'qualifi_name',title:'qualifi_name',width:100,align:'right'},
                        {field:'qualifi_major',title:'qualifi_major',width:100,align:'right'},
                        {field:'zgmc',title:'zgmc',width:100,align:'right'},
                        {field:'which_no',title:'页面显示哪个证书号',width:50,align:'right'}
                    ]],
                    url:'/commonDict/personCertDict/getPersonCertDictList',
                    queryParams:{key:$("#search_key").textbox("getValue")},
            
            
                    //左侧表格选中一行触发
                    onClickRow:function(rowIndex, row){
                        selectRow= row;
                        //映射关系表格
                        $("#right_grid").datagrid({
                            singleSelect:true,
                            title:row.qualifi_type+","+row.qualifi_name+","+row.qualifi_major+"添加别名",
                            fit:true,
                            fitColumns:true,
                            collapsible:true, 
                            striped:true,
                            rownumbers:true, 
                            url:'/commonDict/personCertDict/getAliasList',
                            columns:[[    
                                {field:'CK',checkbox:true},  
                                {field:'data_source',title:'数据源',width:20,align:'right'}, 
                                {field:'cert_name_alias',title:'证书类别别名',width:100,align:'right'},    
                                {field:'profession_alias',title:'专业别名',width:100,align:'right'}
                            ]],
                            queryParams:{cert_dict_id:row.cert_dict_id}
                        });
                    }
                });
        
                //左侧查询按钮
                $("#search_btn").click(function(){
                    $("#grid").datagrid({
                        url:'/commonDict/personCertDict/getPersonCertDictList',
                        queryParams:{key:$("#search_key").textbox("getValue")}
                    });
                });
                
                //左侧添加按钮
                $("#add_btn").click(function(){
                    $("#add_dialog").dialog({ 
                        title: '添加',    
                        width: 800,    
                        height: 600,    
                        closed: false,    
                        cache: false,
                        modal: true,
                        buttons:[{
                            text:'保存',
                            iconCls:'icon-save',
                            handler:function(){
                                $.post("/commonDict/personCertDict/insertPersonCertDict",parent.getFormJson($('#add_form')),function(response){
                                    $("#add_dialog").dialog('close');
                                    $("#grid").datagrid('reload');
                                })
                            }
                        }]
                    });
                });
                
                //左侧修改按钮
                $("#edit_btn").click(function(){
                    var rows = $('#grid').datagrid('getSelections');
                    if(rows.length<1){
                        $.messager.alert('提示','请勾选一条');
                        return false;
                    }
                    $("#edit_cert_dict_id").textbox("setValue", rows[0].cert_dict_id);
                    $("#edit_qualifi_type").textbox("setValue", rows[0].qualifi_type);
                    $("#edit_qualifi_name").textbox("setValue", rows[0].qualifi_name);
                    $("#edit_qualifi_major").textbox("setValue", rows[0].qualifi_major);
                    $("#edit_zgmc").textbox("setValue", rows[0].zgmc);
                    $("#edit_which_no").textbox("setValue", rows[0].which_no);
                    console.log(rows[0])
                    $("#edit_dialog").dialog({ 
                        title: '修改',    
                        width: 800,    
                        height: 600,    
                        closed: false,    
                        cache: false,
                        modal: true,
                        buttons:[{
                            text:'保存',
                            iconCls:'icon-save',
                            handler:function(){
                                $.post("/commonDict/personCertDict/updatePersonCertDict",parent.getFormJson($('#edit_form')),function(response){
                                    $("#edit_dialog").dialog('close');
                                    $("#grid").datagrid('reload');
                                })
                            }
                        }]
                    });
                });
        
                //右侧添加按钮
                $("#right_add_btn").click(function(){
                    $("#add_cert_dict_id").textbox("setValue", selectRow.cert_dict_id);
                    $("#right_add_dialog").dialog({ 
                        title: '添加别名',    
                        width: 600,    
                        height: 300,    
                        closed: false,    
                        cache: false,
                        modal: true,
                        buttons:[{
                            text:'保存',
                            iconCls:'icon-save',
                            handler:function(){
                                $.post("/commonDict/personCertDict/insertAlias",parent.getFormJson($('#right_add_form')),function(response){
                                    $("#right_add_dialog").dialog('close');
                                    $("#right_grid").datagrid('reload');
                                })
                            }
                        }]
                    });
                });
            
                //右侧编辑按钮	
                $("#right_edit_btn").click(function(){
                    var rows = $('#right_grid').datagrid('getSelections');
                    if(rows.length<1){
                        $.messager.alert('提示','请勾选一条');
                        return false;
                    }
                    $("#edit_alias_id").textbox("setValue", rows[0].alias_id);
                    $("#edit_data_source").textbox("setValue", rows[0].data_source);
                    $("#edit_cert_name_alias").textbox("setValue", rows[0].cert_name_alias);
                    $("#edit_profession_alias").textbox("setValue", rows[0].profession_alias);
                    $("#edit_person_type_alias").textbox("setValue", rows[0].person_type_alias);
                    $("#right_edit_dialog").dialog({ 
                        title: '修改别名',    
                        width: 600,    
                        height: 300,    
                        closed: false,    
                        cache: false,
                        modal: true,
                        buttons:[{
                            text:'保存',
                            iconCls:'icon-save',
                            handler:function(){
                                $.post("/commonDict/personCertDict/updateAlias",parent.getFormJson($('#right_edit_form')),function(response){
                                    $("#right_edit_dialog").dialog('close');
                                    $("#right_grid").datagrid('reload');
                                })
                            }
                        }]
                    });
                    
                });

                //右侧删除按钮
                $("#right_del_btn").click(function(){
                    var rows = $('#right_grid').datagrid('getSelections');
                    if(rows.length<1){
                        $.messager.alert('提示','请勾选一条');
                        return false;
                    }
                    alias_id = rows[0].alias_id;
                    $.post("/commonDict/personCertDict/deleteAlias",{alias_id:alias_id},function(response){
                    	$("#right_grid").datagrid('reload');
					})

                });

                
                //右侧显示未匹配按钮		
                $("#show_un_match_btn").click(function(){
                    $("#show_un_match_grid").datagrid({
                        singleSelect:true,
                        fit:true,
                        fitColumns:true,
                        collapsible:true, 
                        striped:true,
                        rownumbers:true, 
                        url:'/commonDict/personCertDict/getUnMatchList',
                        columns:[[    
                            {field:'CK',checkbox:true},
                            
                            {field:'cert_type',title:'证书类别',width:100,align:'center'},    
                            {field:'profession',title:'专业',width:100,align:'center'},
                            {field:'data_source_name',title:'数据源',width:100,align:'center'}
                        ]],
                        pagination:true,
                        pageSize:20,
                        pageList:[10,20,30,50,100,200,500]
                    });
                    $("#show_un_match_dialog").dialog({ 
                        title: '查看未匹配数据',    
                        width: 1000,    
                        height: 600,    
                        closed: false,    
                        cache: false,
                        modal: false,
                        maximizable:true,minimizable:true,collapsible:true,resizable:true
                    });
                });
        

            });
        
        </script>
    </head>
    
	<body class="easyui-layout">
		<!-- 主表格 -->
		<div region="center" border="true" width= "70%">
			<table id="grid" data-options = "toolbar:'#tb'">
				<div id = "tb">
					关键字：<input class="easyui-textbox" id="search_key"  name="key" style="width:400px"  />
					<a href="#" id="search_btn" class="easyui-linkbutton"	 data-options="iconCls:'icon-search'"  >查询</a>
					<a href="#" id='add_btn' class="easyui-linkbutton" data-options="iconCls:'icon-add'">新增</a>
					<a href="#" id='edit_btn' class="easyui-linkbutton" data-options="iconCls:'icon-edit'">编辑</a>
				</div>
			</table>
        </div>
        
		<div region="east" border="true"    width= "30%"  data-options="split:true">
   			<div title="映射关系维护" width= "100%" height = "100%" style="height:1080px">   
				<a href="#" id='right_add_btn' class="easyui-linkbutton" data-options="iconCls:'icon-add'">新增</a>
				<a href="#" id='right_edit_btn' class="easyui-linkbutton" data-options="iconCls:'icon-edit'">编辑</a>
				<a href="#" id='right_del_btn' class="easyui-linkbutton" data-options="iconCls:'icon-edit'">删除</a>
				<a href="#" id='show_un_match_btn' class="easyui-linkbutton" data-options="iconCls:'icon-edit'">查看未匹配数据</a>
				<table id="right_grid" ></table>
			</div>
		</div>
		
		<!-- 一些隐藏的对话框 -->
		<!-- 左侧新增页 -->
		<div style="display:none" id="add_dialog">
			<form id ="add_form" method="post" >
				<table width="100%">
					<tr>
						<td align="right" width="20%">证书类别:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"   name="cert_name" style="width:200px"  />
						</td>
					<tr>
					</tr>
						<td align="right" width="20%">专业:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"   name="profession" style="width:200px"  />
						</td>
						<td width="20%" ></td>
					</tr>
					</tr>
						<td align="right" width="20%">人员类别:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"   name="person_type" style="width:200px"  />
						</td>
						<td width="20%" ></td>
                    </tr>
                    <tr>
                        <td align="right" width="20%">前台显示证书号:</td>
                        <td width="20%"  align="left">
                            <input class="easyui-textbox"   name="which_no" style="width:200px"  />
                        </td>
                        <td width="20%" ></td>
                    </tr>
				</table> 
			</form>
		</div>
		
		<!-- 左侧修改页 -->
		<div style="display:none" id="edit_dialog">
			<form id ="edit_form" method="post" >   
				<table width="100%">
					
					<tr style="display:none">
						<td align="right" width="20%">id:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_cert_dict_id"  name="cert_dict_id" style="width:400px"  />
						</td>
					<tr>
					
					<tr>
						<td align="right" width="20%">qualifi_type:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_qualifi_type"  name="qualifi_type" style="width:400px"  />
						</td>
					<tr>
					</tr>
						<td align="right" width="20%">qualifi_name:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"  id="edit_qualifi_name"  name="qualifi_name" style="width:400px"  />
						</td>
						<td width="20%" ></td>
					</tr>
					</tr>
						<td align="right" width="20%">qualifi_major:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"  id="edit_qualifi_major"   name="qualifi_major" style="width:400px"  />
						</td>
						<td width="20%" ></td>
                    </tr>
                    </tr>
                        <td align="right" width="20%">zgmc:</td>
                        <td width="20%"  align="left">
                            <input class="easyui-textbox"  id="edit_zgmc"   name="zgmc" style="width:400px"  />
                        </td>
                        <td width="20%" ></td>
                    </tr>
                    <tr>
                        <td align="right" width="20%">前台显示证书号:</td>
                        <td width="20%"  align="left">
                            <input class="easyui-textbox" id="edit_which_no"   name="which_no" style="width:400px"  />
                        </td>
                        <td width="20%" ></td>
                    </tr>
				</table> 
			</form>
		</div> 
		
		
		<!-- 右表格一些隐藏的对话框 -->
		<!-- 右新增别名 -->
		<div style="display:none" id="right_add_dialog">
			<form id ="right_add_form" method="post" >
				<table width="100%">
					<tr style="display:none">
						<td align="right" width="20%">id:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="add_cert_dict_id"  name="cert_dict_id" style="width:200px"  />
						</td>
					<tr>
					<tr>
						<td align="right" width="20%">数据源:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  name="data_source" style="width:200px"  />
						</td>
					<tr>
					<tr>
						<td align="right" width="20%">证书类别别名:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"   name="cert_name_alias" style="width:200px"  />
						</td>
					<tr>
					</tr>
						<td align="right" width="20%">专业别名:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"   name="profession_alias" style="width:200px"  />
						</td>
						<td width="20%" ></td>
					</tr>
					</tr>
						<td align="right" width="20%">人员类别别名:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"   name="person_type_alias" style="width:200px"  />
						</td>
						<td width="20%" ></td>
					</tr>
				</table> 
			</form>
		</div>
		
		<!-- 修改别名 -->
		<div style="display:none" id="right_edit_dialog">
			<form id ="right_edit_form" method="post" >   
				<table width="100%">
					
					<tr style="display:none">
						<td align="right" width="20%">id:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_alias_id"  name="alias_id" style="width:200px"  />
						</td>
					<tr>
					<tr>
						<td align="right" width="20%">数据源:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_data_source"  name="data_source" style="width:200px"  />
						</td>
					<tr>
					<tr>
						<td align="right" width="20%">证书类别别名:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_cert_name_alias"  name="cert_name_alias" style="width:200px"  />
						</td>
					<tr>
					</tr>
						<td align="right" width="20%">专业别名:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"  id="edit_profession_alias"  name="profession_alias" style="width:200px"  />
						</td>
						<td width="20%" ></td>
					</tr>
					</tr>
						<td align="right" width="20%">人员类别别名:</td>
						<td width="20%"  align="left">
							<input class="easyui-textbox"  id="edit_person_type_alias"   name="person_type_alias" style="width:200px"  />
						</td>
						<td width="20%" ></td>
					</tr>
				</table> 
			</form>
		</div> 
		
		
		<!-- 显示未匹配对话框 -->
		<div style="display:none" id="show_un_match_dialog">
			<table id="show_un_match_grid" ></table>
		</div> 
		
	</body>
</html>
